﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Ditto.Models
{
    public class TransactionRepository : ITransactionRepository
    {
        DittoEntities db = new DittoEntities();

        public Transaction GetTransaction(int id)
        {
            return db.Transactions.Include("Item").Include("User").SingleOrDefault(t => t.TransactionID == id);
        }

        public void Add(Transaction trans)
        {
            db.Transactions.AddObject(trans);
        }

        public void Delete(Transaction trans)
        {
            db.Transactions.DeleteObject(trans);
        }

        public void Save()
        {
            db.SaveChanges();
        }
    }
}